import request from '@/utils/request'

/**
 * 
 * @param {原始数据接口} data 
 * @returns 
 */

//原始数据分页查询
export const getList = (data) => {
  return request({
    url: '/original-data/selectByCondition?currentPage=' + data.currentPage + '&size=' + data.size+'&sqlName='+data.sqlName,
    method: 'get'
  })
}

//原始数据数据库查询
export const getDatabase = () => {
  return request({
    url: '/data-base-config/selectList',
    method: 'get'
  })
}

//新增原始数据
export const insertRow = (data) => {
  return request({
    url: '/original-data/insert',
    method: 'post',
    data
  })
}

//查询原始数据详情
export const selectOne = (data) => {
  return request({
    url: '/original-data/selectOne?id='+data.id,
    method: 'get',
  })
}

//格式化SQL
export const formatSQL = (data) => {
  return request({
    url: '/original-data/formatSQL',
    method: 'post',
    data
  })
}

//SQL效验
export const validateSQL = (data) => {
  return request({
    url: '/original-data/validateSQL',
    method: 'post',
    data
  })
}

export const getTableName = (data) => {
  return request({
    url: '/original-data/getTableName?sqlContent='+data.sqlContent,
    method: 'get',
  })
}



//编辑原始数据
export const updateRow = (data) => {
  return request({
    url: '/original-data/updateByCondition',
    method: 'post',
    data
  })
}

//批量删除原始数据
export const delateRow = (data) => {
  return request({
    url: '/original-data/batchDelete',
    method: 'post',
    data
  })
}

//新增查询原始数据名称重命名效验
export const insertRules = (data) => {
  return request({
    url: '/original-data/existsSqlName?sqlName='+data,
    method: 'get',
  })
}